﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Ecobee.Net
{
	public class WeatherForecast : ApiObject
	{
		#region Private Fields
		private int _weatherSymbol = 0;
		private DateTime _dateTime = DateTime.MinValue;
		private string _condition = string.Empty;
		private ApiTemperature _temperature = 0;
		private int _pressure = 0;
		private int _relativeHumidity = 0;
		private int _dewpoint = 0;
		private int _visibility = 0;
		private int _windSpeed = 0;
		private int _windGust = 0;
		private string _windDirection = string.Empty;
		private int _windBearing = 0;
		private int _pop = 0;
		private ApiTemperature _tempHigh = 0;
		private ApiTemperature _tempLow = 0;
		private int _sky = 0;
		#endregion

		[JsonIgnore]
		public override string UniqueKey
		{
			get
			{
				return this.DateTime.ToString();
			}
		}

		/// <summary>
		/// 
		/// </summary>
		[JsonProperty(PropertyName = "weatherSymbol")]
		public int WeatherSymbol
		{
			get
			{
				return _weatherSymbol;
			}
			set
			{
				_weatherSymbol= value;
			}
		}

		/// <summary>
		/// The time stamp of the weather forecast. 
		/// </summary>
		[JsonProperty(PropertyName = "dateTime")]
		public DateTime DateTime
		{
			get
			{
				return _dateTime;
			}
			set
			{
				_dateTime= value;
			}
		}

		[JsonProperty(PropertyName = "condition")]
		public string Condition
		{
			get
			{
				return _condition;
			}
			set
			{
				_condition= value;
			}
		}

		/// <summary>
		/// The current temperature. 
		/// </summary>
		[JsonProperty(PropertyName = "temperature")]
		public ApiTemperature Temperature
		{
			get
			{
				return _temperature;
			}
			set
			{
				_temperature= value;
			}
		}

		/// <summary>
		/// The current barometric pressure. 
		/// </summary>
		[JsonProperty(PropertyName = "pressure")]
		public int Pressure
		{
			get
			{
				return _pressure;
			}
			set
			{
				_pressure= value;
			}
		}

		/// <summary>
		/// The current humidity. 
		/// </summary>
		[JsonProperty(PropertyName = "relativeHumidity")]
		public int RelativeHumidity
		{
			get
			{
				return _relativeHumidity;
			}
			set
			{
				_relativeHumidity= value;
			}
		}

		/// <summary>
		/// The dewpoint. 
		/// </summary>
		[JsonProperty(PropertyName = "dewpoint")]
		public int Dewpoint
		{
			get
			{
				return _dewpoint;
			}
			set
			{
				_dewpoint= value;
			}
		}

		[JsonProperty(PropertyName = "visibility")]
		public int Visibility
		{
			get
			{
				return _visibility;
			}
			set
			{
				_visibility= value;
			}
		}

		/// <summary>
		/// The wind speed in mph. 
		/// </summary>
		[JsonProperty(PropertyName = "windSpeed")]
		public int WindSpeed
		{
			get
			{
				return _windSpeed;
			}
			set
			{
				_windSpeed= value;
			}
		}

		[JsonProperty(PropertyName = "windGust")]
		public int WindGust
		{
			get
			{
				return _windGust;
			}
			set
			{
				_windGust= value;
			}
		}

		/// <summary>
		/// The wind direction. 
		/// </summary>
		[JsonProperty(PropertyName = "windDirection")]
		public string WindDirection
		{
			get
			{
				return _windDirection;
			}
			set
			{
				_windDirection= value;
			}
		}

		/// <summary>
		/// The wind bearing. 
		/// </summary>
		[JsonProperty(PropertyName = "windBearing")]
		public int WindBearing
		{
			get
			{
				return _windBearing;
			}
			set
			{
				_windBearing= value;
			}
		}

		/// <summary>
		/// Probability of precipitation. 
		/// </summary>
		[JsonProperty(PropertyName = "pop")]
		public int Pop
		{
			get
			{
				return _pop;
			}
			set
			{
				_pop= value;
			}
		}

		/// <summary>
		/// The predicted high temperature for the day. 
		/// </summary>
		[JsonProperty(PropertyName = "tempHigh")]
		public ApiTemperature TempHigh
		{
			get
			{
				return _tempHigh;
			}
			set
			{
				_tempHigh= value;
			}
		}

		/// <summary>
		/// The predicted low temperature for the day. 
		/// </summary>
		[JsonProperty(PropertyName = "tempLow")]
		public ApiTemperature TempLow
		{
			get
			{
				return _tempLow;
			}
			set
			{
				_tempLow= value;
			}
		}

		/// <summary>
		/// The cloud cover condition. 
		/// </summary>
		[JsonProperty(PropertyName = "sky")]
		public int Sky
		{
			get
			{
				return _sky;
			}
			set
			{
				_sky= value;
			}
		}

		protected override string OnDeserializeKeyValue(dynamic dataObject)
		{
			return dataObject.dateTime;
		}
	}
}
